if (window['tt']) {
    window.miniPlatform = (function () {
        function miniPlatform() { };
        miniPlatform.loginCount = 0;
        miniPlatform.systemInfo = null;

        miniPlatform.init = function () {
            console.log("头条平台初始化...");
            if (!window.tt) {
                return;
            }
            window.tt.showShareMenu({
                withShareTicket: true
            });
            miniPlatform.systemInfo = tt.getSystemInfoSync();
        }

        miniPlatform.initAds = function ({ bannerid, videoid, interid }) {
            ii.log.log(`bannerid  ${bannerid}  videoid ${videoid}  interid ${interid}`);
            miniPlatform.initBanner({ id: bannerid });
            miniPlatform.initVideo({ id: videoid });
            miniPlatform.initInterstitialAd({ id: interid });
        }

        miniPlatform.login = function _async() {
            return new Promise((resolve, reject) => {
                tt.login({
                    force: false,
                    success: (result) => {
                        if (result.code || result.anonymousCode) {
                            resolve({
                                code: result.code,
                                anonymous_code: result.anonymousCode
                            });
                        }
                        else {
                            resolve({
                                uid: 1
                            });
                        }
                    },
                    fail: (result) => {
                        resolve({
                            uid: 1
                        });
                    },
                    complete: (result) => { }
                });
            });
        }

        miniPlatform.share = function (params) {
            var desc = (params && params.desc) ? params.desc : "";
            var title = (params && params.title) ? params.title : "";
            var imgUrl = (params && params.imgUrl) ? params.imgUrl : "";
            var query = (params && params.query) ? params.query : ""
            if (title == null) {
                console.warn('方法（ share ）缺少必要参数（ title ）', 'miniPlatform');
                return;
            }
            if (imgUrl == null) {
                console.warn('方法（ share ）缺少必要参数（ imgUrl ）', 'miniPlatform');
                return;
            }
            // if (desc == null) {
            //     console.warn('方法（ share ）缺少必要参数（ desc ）', 'miniPlatform');
            //     return;
            // }
            // if (params.query == null) {
            //     console.warn('方法（ share ）缺少必要参数（ query ）', 'miniPlatform');
            //     return;
            // }
            tt.shareAppMessage({
                title: title,
                imageUrl: imgUrl,
                desc: desc,
                query: query,
                success(res) {
                    console.log('分享成功', JSON.stringify(res));
                    if (params && params.success) {
                        params.success();
                    }
                },
                fail(err) {
                    console.log('分享失败', JSON.stringify(err));
                    if (params && params.fail) {
                        params.fail();
                    }
                }
            });
        }

        miniPlatform.setDefaultShare = function (params) {
            if (params.title == null) {
                console.warn('方法（ share ）缺少必要参数（ title ）', 'miniPlatform');
                return;
            }
            if (params.imgUrl == null) {
                console.warn('方法（ share ）缺少必要参数（ imgUrl ）', 'miniPlatform');
                return;
            }
            var shareInfo = {
                title: params.title,
                imageUrl: params.imgUrl
            }
            tt.onShareAppMessage(() => shareInfo)
        }


        miniPlatform.loadSubpackage = function _async(params) {
            return new Promise((resolve, reject) => {
                if (params.pkgName == null) {
                    console.warn('方法（ loadSubpackage ）缺少必要参数（ pkgName ）', 'miniPlatform');
                    return reject();
                }
                if (tt.loadSubpackage) {
                    let loadTask = tt.loadSubpackage({
                        name: params.pkgName,
                        success: (result) => {
                            resolve(result);
                        },
                        fail: (result) => {
                            reject(result);
                        }
                    });
                    if (loadTask) {
                        if (params.progressHandler) {
                            loadTask.onProgressUpdate((result) => {
                                progressHandler.runWith(result.progress);
                            });
                        }
                    } else {
                        reject();
                    }
                } else {
                    reject();
                }
            });
        }

        miniPlatform.onVideoErrorHandler = function (error) {
            var msg = '未知错误!';
            try {
                if (error) {
                    msg = `${error.errCode}:${error.errMsg}`
                }
            } catch (error) { }
            miniPlatform.videoErrorHandler && miniPlatform.videoErrorHandler(msg);
        }

        miniPlatform.onVideoCloseHandler = function (result) {
            if ((result && result.isEnded) || result == undefined) {
                miniPlatform.videoCloseHandler && miniPlatform.videoCloseHandler(true);
            } else {
                miniPlatform.videoCloseHandler && miniPlatform.videoCloseHandler(false);
            }
        }

        miniPlatform.initVideo = function (params) {
            if (!window.tt || typeof window.tt.createRewardedVideoAd != 'function') {
                return;
            }
            if (!params.id || params.id == null || params.id.length <= 0) {
                console.warn('方法（ initVideo ）缺少必要参数（ id ）', 'miniPlatform');
                miniPlatform.videoAd = null;
                return;
            }
            miniPlatform.videoId = params.id;
            miniPlatform.videoAd = tt.createRewardedVideoAd({ adUnitId: params.id });
            if (miniPlatform.videoAd) {
                miniPlatform.videoAd.onError(miniPlatform.onVideoErrorHandler);
                miniPlatform.videoAd.onClose(miniPlatform.onVideoCloseHandler);
            }
        }

        miniPlatform.playVideo = function _async() {
            return new Promise((resolve, reject) => {
                if (miniPlatform.videoAd == null) { return reject(null); }
                miniPlatform.videoCloseHandler = (result) => {
                    if (!result) {
                        miniPlatform.showModel({
                            title: "未观看完视频",
                            content: "观看完视频才能获得奖励哦",
                            showCancel: true
                        }).then((sure) => {
                            if (sure) {
                                miniPlatform.playVideo().then((isEnd) => {
                                    resolve(isEnd);
                                }).catch((error) => {
                                    var msg = '未知错误!';
                                    try {
                                        if (error) {
                                            msg = `${error.errCode}:${error.errMsg}`
                                        }
                                    } catch (error) { }
                                    reject(msg);
                                })
                            }
                            else {
                                resolve(false);
                            }
                        }).catch((error) => {
                            resolve(false);
                        })
                    }
                    else {
                        resolve(true);
                    }
                };
                miniPlatform.videoAd.show().catch((error) => {
                    miniPlatform.videoAd.load().then(() => {
                        miniPlatform.videoAd.show().catch((error) => {
                            var msg = '未知错误!';
                            try {
                                if (error) {
                                    msg = `${error.errCode}:${error.errMsg}`
                                }
                            } catch (error) { }
                            reject(msg);
                        })
                    }).catch((error) => {
                        var msg = '未知错误!';
                        try {
                            if (error) {
                                msg = `${error.errCode}:${error.errMsg}`
                            }
                        } catch (error) { }
                        reject(msg);
                    })
                });
            })
        }

        miniPlatform.isVideoEnable = function () {
            return miniPlatform.videoAd != null;
        }

        miniPlatform.request = function _async(params) {
            if (params.url == null || params.url.length <= 0) {
                console.warn('方法（ request ）缺少必要参数（ url ）', 'miniPlatform');
                miniPlatform.bannerAd = null;
                return;
            }
            if (params.data == null) {
                console.warn('方法（ request ）缺少必要参数（ data ）', 'miniPlatform');
                return;
            }
            if (params.method == null) {
                console.warn('方法（ request ）缺少必要参数（ method ）', 'miniPlatform');
                return;
            }
            return new Promise((resolve, reject) => {
                tt.request({
                    url: url,
                    data: data,
                    header: { 'content-type': 'application/json' },
                    method: method,
                    dataType: null,
                    responseType: null,
                    success: (result) => {
                        resolve(result);
                    },
                    fail: () => {
                        reject();
                    },
                    complete: () => { }
                });
            });
        }

        miniPlatform.initBanner = function (params) {
            if (!window.tt || typeof window.tt.createBannerAd != 'function' || !(params && params.id)) {
                return;
            }
            miniPlatform.bannerId = params.id;
            if (miniPlatform.bannerId.length <= 0 || miniPlatform.bannerId == null) {
                console.warn('方法（ initBanner ）缺少必要参数（ id ）', 'miniPlatform');
                miniPlatform.bannerAd = null;
                return;
            }
            miniPlatform.keepTime = 30;
            miniPlatform.bannerType = "normal";//默认banner类型
            let systemInfo = miniPlatform.systemInfo;
            let targetBannerAdWidth = 150;
            let targetBannerAdTop = systemInfo.windowHeight - (targetBannerAdWidth / 16) * 9;
            let targetBannerAdLeft = (systemInfo.windowWidth - targetBannerAdWidth) / 2;
            // console.log("init style:", targetBannerAdLeft, targetBannerAdTop, targetBannerAdWidth)
            miniPlatform.bannerAd = tt.createBannerAd({
                adUnitId: miniPlatform.bannerId,
                adIntervals: miniPlatform.keepTime,
                style: {
                    left: targetBannerAdLeft,
                    top: targetBannerAdTop,
                    width: targetBannerAdWidth
                }
            });
            if (miniPlatform.bannerAd == null) { return; }
            miniPlatform.bannerAd.onResize((size) => {
                console.log("banner resize:", size.width, size.height)
                miniPlatform.bannerStyle = size;
                if (miniPlatform.bannerAd) {
                    if (miniPlatform.bannerType == "pixel") {
                        var pixel = 1;
                        miniPlatform.bannerAd.style.top = window.screen.availHeight - pixel;
                        miniPlatform.bannerAd.style.left = pixel - miniPlatform.bannerStyle.width;
                    } else {
                        console.log("wxd onresize()准备修改banner style:", (miniPlatform.systemInfo.windowWidth - size.width) / 2, miniPlatform.systemInfo.windowHeight - size.height)
                        miniPlatform.bannerAd.style.top = miniPlatform.systemInfo.windowHeight - size.height;
                        miniPlatform.bannerAd.style.left = (miniPlatform.systemInfo.windowWidth - size.width) / 2;
                    }
                }
            });
            miniPlatform.bannerAd.onError((error) => {
                miniPlatform.bannerAd = null;
            });
        }

        miniPlatform.showBanner = function () {
            miniPlatform.bannerType = "normal";
            if (miniPlatform.bannerId == null) { return; }
            if (miniPlatform.bannerAd == null) {
                miniPlatform.initBanner();
            }
            if (miniPlatform.bannerAd) {
                if (miniPlatform.bannerStyle) {
                    console.log("wxd show()准备修改banner style:", (miniPlatform.systemInfo.windowWidth - miniPlatform.bannerStyle.width) / 2, miniPlatform.systemInfo.windowHeight - miniPlatform.bannerStyle.height)
                    miniPlatform.bannerAd.style.top = miniPlatform.systemInfo.windowHeight - miniPlatform.bannerStyle.height;
                    miniPlatform.bannerAd.style.left = (miniPlatform.systemInfo.windowWidth - miniPlatform.bannerStyle.width) / 2;
                }
                miniPlatform.bannerAd.show();
            }
        }

        /**显示单像素banner */
        miniPlatform.showOnePixelBanner = function () {
            miniPlatform.bannerType = "pixel";
            if (miniPlatform.bannerId == null) { return; }
            if (miniPlatform.bannerAd == null) {
                miniPlatform.initBanner();
            }
            if (miniPlatform.bannerAd) {
                if (miniPlatform.bannerStyle) {
                    var pexel = 1;
                    miniPlatform.bannerAd.style.top = window.screen.availHeight - pexel;
                    miniPlatform.bannerAd.style.left = pexel - miniPlatform.bannerStyle.width;
                }
                miniPlatform.bannerAd.show();
            }
        }

        miniPlatform.hideBanner = function () {
            miniPlatform.bannerAd && miniPlatform.bannerAd.hide();
        }

        miniPlatform.initInterstitialAd = function (params) {
            if (!window.tt || typeof window.tt.createInterstitialAd != 'function') {
                return;
            }
            miniPlatform.insertId = params.id;
        }

        miniPlatform.showInterstitialAd = function _async() {
            return new Promise((resolve, reject) => {
                if (!window['tt']) {
                    console.log("显示插屏 showInterstitialAd");
                    return;
                }
                if (miniPlatform.insertId == null || miniPlatform.insertId.length <= 0) {
                    console.warn('方法（ initInsert ）缺少必要参数（ id ）', 'miniPlatform');
                    reject();
                    return;
                }
                miniPlatform.insertAd = tt.createInterstitialAd({ adUnitId: miniPlatform.insertId });
                if (miniPlatform.insertAd) {
                    miniPlatform.insertAd.onError((error) => {
                        reject(error);
                        miniPlatform.insertAd && miniPlatform.insertAd.destroy();
                    });
                    miniPlatform.insertAd.onClose(() => {
                        resolve();
                        miniPlatform.insertAd && miniPlatform.insertAd.destroy();
                    });
                    miniPlatform.insertAd.load().then(() => {
                        miniPlatform.insertAd.show();
                    });
                } else {
                    reject(error);
                }
            });
        }

        miniPlatform.curTime = 0;
        /**
         * 开始录屏
         * @param {*} params
         */
        miniPlatform.recorderStart = function (params = {}) {
            if (!window['tt']) {
                console.log("开始录屏 recorderStart");
                return;
            }
            params.maxTime = params.maxTime || 300;
            if (typeof window.tt.getGameRecorderManager === 'function') {
                if (miniPlatform.recoding) {
                    miniPlatform.isPause && miniPlatform.recorderResume();
                    return;
                }
                const recorder = tt.getGameRecorderManager();
                miniPlatform.bHighLightRecorder = false
                miniPlatform.startTime = 0;
                miniPlatform.stopTime = 0;
                miniPlatform.curTime = 0;
                miniPlatform.isPause = false;
                console.log("又进这里了");
                recorder.onStart(() => {
                    miniPlatform.recoding = true;
                    miniPlatform.startTime = Date.now();
                    miniPlatform.stopCallBack = null;
                    console.log("录屏开始", miniPlatform.curTime, miniPlatform.startTime, miniPlatform.stopTime);
                });
                recorder.onStop((result) => {
                    console.log("停止录屏回调", JSON.stringify(result));
                    miniPlatform.recoding = false;
                    miniPlatform.videoPath = result.videoPath;
                    miniPlatform.stopTime = Date.now();
                    console.log("录屏结束", miniPlatform.curTime, miniPlatform.startTime, miniPlatform.stopTime);
                    if (miniPlatform.bHighLightRecorder) {
                        console.log("有高光录屏");
                        recorder.clipVideo({
                            path: result.videoPath,
                            success(res) {
                                console.log("剪辑最后视频成功");
                                miniPlatform.videoPath = res.videoPath;
                                miniPlatform.stopCallBack && miniPlatform.stopCallBack();
                            },
                            fail(e) {
                                console.log("剪辑视频失败");
                                miniPlatform.stopCallBack && miniPlatform.stopCallBack();
                            }
                        })
                    } else if (((miniPlatform.curTime + miniPlatform.stopTime - miniPlatform.startTime)) > 30000) {
                        recorder.clipVideo({
                            path: result.videoPath,
                            timeRange: [30, 0], //剪辑最后30秒
                            success(res) {
                                console.log(`剪辑最后视频成功`)
                                miniPlatform.videoPath = res.videoPath;
                                miniPlatform.stopCallBack && miniPlatform.stopCallBack();
                            },
                            fail(e) {
                                console.error("剪辑视频失败")
                                miniPlatform.stopCallBack && miniPlatform.stopCallBack();
                            }
                        })
                    } else {
                        console.log("录屏时间小于30s,无需剪辑")
                        miniPlatform.stopCallBack && miniPlatform.stopCallBack();
                    }
                });

                recorder.start({
                    duration: params.maxTime,
                });
            }
        }

        miniPlatform.recorderStop = function (params) {
            console.log("调用录屏结束", miniPlatform.curTime, miniPlatform.startTime, miniPlatform.stopTime, miniPlatform.recoding);
            if (!window.tt || !miniPlatform.recoding) { params && params.callback && params.callback(); return; }
            if (typeof window.tt.getGameRecorderManager === 'function') {
                miniPlatform.stopCallBack = (params && params.callback) ? params.callback : null;
                const recorder = tt.getGameRecorderManager();
                recorder.stop();
                miniPlatform.isPause = false;
            }
        }

        miniPlatform.recorderPause = function () {
            console.log("调用录屏暂停", miniPlatform.curTime, miniPlatform.startTime, miniPlatform.stopTime);
            if (!window.tt || !miniPlatform.recoding) { return; }
            if (typeof window.tt.getGameRecorderManager === 'function') {
                const recorder = tt.getGameRecorderManager();
                recorder.pause();
                miniPlatform.isPause = true;
                miniPlatform.curTime = Date.now() - miniPlatform.startTime;
                console.log("调用录屏暂停", miniPlatform.curTime, miniPlatform.startTime, miniPlatform.stopTime);
                miniPlatform.startTime = Date.now();
                miniPlatform.stopTime = Date.now();
                console.log("调用录屏暂停", miniPlatform.curTime, miniPlatform.startTime, miniPlatform.stopTime);
            }
        }
        miniPlatform.recorderResume = function () {
            console.log("调用录屏继续", miniPlatform.curTime, miniPlatform.startTime, miniPlatform.stopTime);
            if (!window.tt || !miniPlatform.recoding) { return; }
            if (typeof window.tt.getGameRecorderManager === 'function') {
                const recorder = tt.getGameRecorderManager();
                recorder.resume();
                miniPlatform.isPause = false;
                miniPlatform.startTime = Date.now();
                miniPlatform.stopTime = 0;
            }
        }


        /**裁剪高光时刻 */
        miniPlatform.recorderClip = function (params) {
            if (!window.tt || !miniPlatform.recoding) { return; }
            if (params.beforeTime == null) {
                console.warn('方法（ recorderClip ）缺少必要参数（ beforeTime ）', 'miniPlatform');
                return;
            }
            if (params.laterTime == null) {
                console.warn('方法（ recorderClip ）缺少必要参数（ laterTime ）', 'miniPlatform');
                return;
            }
            if (typeof window.tt.getGameRecorderManager === 'function') {
                const recorder = tt.getGameRecorderManager();
                miniPlatform.bHighLightRecorder = true;
                recorder.recordClip({
                    timeRange: [params.beforeTime, params.laterTime]
                })
            }
        }
        /**分享录屏 */
        miniPlatform.shareRecorderVideo = function _async(params = {}) {
            return new Promise((resolve, reject) => {
                console.log("开始分享录屏", miniPlatform.videoPath);
                console.log("录屏时长：", (miniPlatform.curTime + (miniPlatform.stopTime - miniPlatform.startTime)))
                if (!window.tt || miniPlatform.videoPath == '') {
                    reject();
                    return;
                }
                var topic = params.topic ? params.topic : "";
                var topics = [];
                if (topic != "") {
                    topics = topic.split(",");
                }
                // var queryData = `commandId=${zs.core.userId}&from=videoShare`;
                var desc = params.desc ? params.desc : "";
                var title = params.title ? params.title : "";
                var imgUrl = params.imgUrl ? params.imgUrl : "";
                let shareInfo = {
                    channel: 'video',
                    desc: desc,
                    title: title,
                    imageUrl: imgUrl,
                    // query: queryData,
                    extra: {
                        videoPath: miniPlatform.videoPath,
                        videoTopics: topics, // 视频话题(只在抖音可用) （目前由 hashtag_list 代替），为保证兼容性，建议同时填写两个
                        hashtag_list: topics, // 视频话题(只在抖音可用)
                        withVideoId: true,
                        video_title: title, // 生成输入的默认文案
                    },
                    success(res) {
                        var videoId = res && res.videoId;
                        if (videoId) {
                            console.log('分享出去有视频id', videoId);
                        }
                        resolve();
                    },
                    fail(err) {
                        console.log('分享录屏失败', JSON.stringify(err));
                        reject();
                    }
                };
                console.log('分享录屏', shareInfo);
                tt.shareAppMessage(shareInfo);
            });
        }

        /**
         * 显示头条更多好玩
         * @returns 
         */
        miniPlatform.showMoreGamesModalSimple = function _async() {
            return new Promise((resolve, reject) => {
                if (!window.tt || typeof window.tt.showMoreGamesModal != 'function') {
                    reject();
                    return;
                }
                tt.offNavigateToMiniProgram(); //取消所有监听
                tt.offMoreGamesModalClose();
                // 监听弹窗关闭
                tt.onMoreGamesModalClose((res) => {
                    console.log("modal closed", res);
                });
                // 监听小游戏跳转
                tt.onNavigateToMiniProgram((res) => {
                    if (res) {
                        console.log("是否有跳转的小游戏", res);
                        if (res.errCode == 0) {
                            resolve(true);
                        } else {
                            resolve(false);
                        }

                    }
                });
                // iOS 不支持，建议先检测再使用
                var navigateData = {};
                navigateData.appId = zs.core.appId;
                if (miniPlatform.systemInfo.miniPlatform !== "ios") {
                    // 打开互跳弹窗
                    tt.showMoreGamesModal({
                        appLaunchOptions: [
                            {
                                extraData: navigateData
                            }
                        ],
                        success(res) {
                            console.log("showMoreGamesModal success", res.errMsg);
                        },
                        fail(res) {
                            console.log("showMoreGamesModal fail", res.errMsg);
                        }
                    });
                }
            })
        }

        /**
         * 调起关注小程序的引导组件
         * @returns 
         */
        miniPlatform.showFavoriteGuide = function () {
            if (!window.tt || typeof window.tt.showFavoriteGuide != 'function') {
                return;
            }
            tt.showFavoriteGuide({
                type: "bar",
                content: "一键添加到我的小程序",
                position: "bottom",
            })
        }

        miniPlatform.showModel = function (params) {
            if (!window.tt || typeof window.tt.showModal != 'function') {
                return;
            }
            params = params || {};
            return new Promise((resolve, reject) => {
                tt.showModal({
                    title: params.title || "提示",
                    content: params.content || "内容",
                    confirmText: params.confirmText || "确定",
                    cancelText: params.cancelText || "取消",
                    showCancel: params.showCancel || false,
                    success(res) {
                        if (res.confirm) {
                            resolve(true);
                        } else if (res.cancel) {
                            resolve(false);
                        } else {
                            reject();
                        }
                    },
                    fail(res) {
                        reject();
                    },
                });
            });
        }

        miniPlatform.canShareRecorder = function () {
            console.log("分享录屏", miniPlatform.curTime, miniPlatform.startTime, miniPlatform.stopTime);
            if (miniPlatform.stopTime > 0) {
                return (miniPlatform.curTime + miniPlatform.stopTime - miniPlatform.startTime) / 1000 > 3;
            }
            else {
                return (miniPlatform.curTime + Date.now() - miniPlatform.startTime) / 1000 > 3;
            }
        }

        miniPlatform.getRecorderTime = function () {
            if (!window.tt || !miniPlatform.recoding) { return 0; }
            if (miniPlatform.startTime > 0) {
                if (miniPlatform.stopTime > 0) {
                    return (miniPlatform.curTime + miniPlatform.stopTime - miniPlatform.startTime) / 1000;
                }
                else {
                    return (miniPlatform.curTime + Date.now() - miniPlatform.startTime) / 1000;
                }
            }
            return 0;
        }

        miniPlatform.statusBarHeight = function () {
            return miniPlatform.systemInfo ? miniPlatform.systemInfo.statusBarHeight : 0;
        }

        miniPlatform.screenWidth = function () {
            return miniPlatform.systemInfo ? miniPlatform.systemInfo.screenWidth : 1;
        }

        miniPlatform.screenHeight = function () {
            return miniPlatform.systemInfo ? miniPlatform.systemInfo.screenHeight : 1;
        }

        miniPlatform.vibrate = function (params) {
            if (params && params.isLong) {
                tt.vibrateLong({
                    fail: () => {
                        console.log("Vibrate Long failed");
                    }
                });
            } else {
                tt.vibrateShort({
                    fail: () => {
                        console.log("vibrate Short failed");
                    }
                });
            }
        }
        miniPlatform.isNetValid = function () {
            return true;
        }
        miniPlatform.addEventShow = function (func) {
            tt.onShow((result) => {
                func && func(result);
            });
        }
        miniPlatform.addEventHide = function (func) {
            tt.onHide((result) => {
                func && func(result);
            });
        }
        miniPlatform.showToast = function (msg) {
            if (!window['tt']) {
                console.error(msg);
                return;
            }
            tt.showToast({
                title: msg,
                duration: 2000,
                icon: "none"
            });
        }
        miniPlatform.reportAnalytics = function (eventName, data = {}) {
            if (!window['tt']) {
                console.log(`打点事件 eventName : ${eventName} + data : ${JSON.stringify(data)}`);
                return;
            }
            tt.reportAnalytics(eventName, data)
        }
        //#region 桌面图标
        miniPlatform.hasDesktopIcon = function _async() {
            //判断是否有桌面图标
            return new Promise((resolve, reject) => {
                if (!tt.checkShortcut) {
                    console.log("不支持添加到桌面");
                    return reject();
                }
                tt.checkShortcut({
                    success(res) {
                        console.log('检查快捷方式', res ? res.status : "???");
                        if (res && res.status && (!res.status.exist || res.status.needUpdate)) {
                            resolve(false);
                        }
                        else {
                            resolve(true);
                        }
                    },
                    fail(res) {
                        console.log('检查快捷方式失败', res.errMsg);
                        reject();
                    },
                });
            })
        }
        //创建桌面图标
        miniPlatform.createDesktopIcon = function _async() {
            return new Promise((resolve, reject) => {
                if (!tt.addShortcut) {
                    return reject();
                }
                tt.addShortcut({
                    success() {
                        console.log("添加桌面成功");
                        resolve();
                    },
                    fail(err) {
                        console.log("添加桌面失败", err.errMsg);
                        reject();
                    },
                });
            })
        }

        return miniPlatform;
    })()
}